#include "led.h"
#include "uart4.h"
#include "beep.h"
#include "motor.h"
#include "interrupt.h"
extern void printf(const char *fmt, ...);
void delay_ms(unsigned int ms)
{
	int i,j;
	for(i = 0; i < ms;i++)
		for (j = 0; j < 1800; j++);
}

extern char  buffer[LEN];
int main()
{
	hal_send_string("key IT test code\n");
	led_init();
	hal_uart4_init();  // 串口的初始化
	// KEY1  PF9
	hal_gpio_IT_init(GPIOF,GPIO_PIN_9, GPIO_INPUT);
	hal_exti_IT_init(GPIO_PIN_9,GPIOF_EXTI,EXTI_FALLING,
						EXTI9_INPUT_EVENT);
	hal_gic_IT_init(EXTI9_ID,EXTI9_PRIORITY);
	// 光电开关   PE15
	hal_gpio_IT_init(GPIOE,GPIO_PIN_15, GPIO_INPUT);
	hal_exti_IT_init(GPIO_PIN_15,GPIOE_EXTI,EXTI_RISING,
						EXTI15_INPUT_EVENT);
	hal_gic_IT_init(EXTI15_ID,EXTI15_PRIORITY);
	// 火焰  PF5
	hal_gpio_IT_init(GPIOF,GPIO_PIN_5, GPIO_INPUT);
	hal_exti_IT_init(GPIO_PIN_5,GPIOF_EXTI,EXTI_RISING,
						EXTI5_INPUT_EVENT);
	hal_gic_IT_init(EXTI5_ID,EXTI5_PRIORITY);

	// 人体红外 PF12
	hal_gpio_IT_init(GPIOF,GPIO_PIN_12, GPIO_INPUT);
	hal_exti_IT_init(GPIO_PIN_12,GPIOF_EXTI,EXTI_RISING,
						EXTI12_INPUT_EVENT);
	hal_gic_IT_init(EXTI12_ID,EXTI12_PRIORITY);
	hal_send_string("hal init finished\n");
	while(1)
	{
		
	}
	return 0;
}
